package com.coder520.sync_learning.demo;

import java.util.concurrent.TimeUnit;

public class ThreadisInterrupted {
    public static void main(String[] args)throws  Exception{
        Thread t1=new Thread(){
            @Override
            public void run() {
                while (true){
                    //System.out.println("thread1我正在运行！");
                }
            }
        };

        t1.start();

        TimeUnit.MILLISECONDS.sleep(2);

        System.out.printf("线程是否已经被打断：%s\n",t1.isInterrupted());

        t1.interrupt();

        System.out.printf("线程是否已经被打断：%s\n",t1.isInterrupted());

    }
}
